<template>
    <div class="wrapper" style="height: 100vh;overflow-x: hidden;">
        <NavMenu></NavMenu>
        <div>
            <div class="module-body grid-content content bg-purple blog_bg" v-model="blogData" >
                <ul>
                    <li class="clearfix"><a class="head-pic" href=""><img src="../../assets/p.png" style="width: 100%" ></a>
                        <div class="discuss-detail">
                            <div class="discuss-main clearfix">
                                    <a href="" target="_blank" style="text-decoration: none;font-weight: bold;">
                                        {{blogData.title}}
                                        <span>置顶</span>
                                        <span>烫</span>
                                    </a>
                            </div>
                            <a href=""></a>
                            <div class="feed-foot">
                                <a href="" target="_blank"></a>
                                <div class="feet-origin">
                                    <p class="feed-tip">
                                        <a href=""></a>
                                        <a href="" style="color: red;text-decoration: none">{{blogData.writer}}</a>
                                        &nbsp;&nbsp;&nbsp;&nbsp;
                                        {{blogData.createTime}} &nbsp;&nbsp;
                                        发表在
                                        <a href="" style="font-size: 12px">[站内公告]</a>
                                        &nbsp;&nbsp;3天前回复
                                    </p>
                                </div>
                                <div class="feed-legend">
                            <span>回复
                                <span>{{blogData.commentCount}}</span>
                            </span>
                                    <span class="feed-legend-pipe">|</span>
                                    <span>赞
                                <span>{{blogData.zan}}</span>
                            </span>
                                    <span class="feed-legend-pipe">|</span>
                                    <span>浏览
                                <span>{{blogData.viewCount}}</span>
                            </span>
                                </div>
                            </div>
                        </div>
                    </li>
                </ul>
            <div class="markdown-body" v-html="blogData.content" style="padding: 40px;"></div>
            </div>
            <!-- 评论 -->
            <Comment :blogId=id style="padding-bottom: 3px;"></Comment>
        </div>

        <!-- 页脚 -->
        <Foot></Foot>
    </div>
</template>

<script>
    import Head from '../../views/component/Head'
    import Foot from '../../views/component/Foot'
    import Comment from '../../views/component/Comment'
    import 'github-markdown-css'
    import "mavon-editor/dist/css/index.css"
    import {getActiceById} from "../../api/blog/blog";
    import NavMenu from "../common/NavMenu";
    export default {
        name: 'Blog',
        components:{NavMenu, Head,Foot,Comment },
        data () {
            return {
                blogData:'', //博客数据
            }
        },
        props:['id'], //接收路由传过来的id
        mounted() {
            this.initActice()
        },
        methods:{
            initActice(){
                console.log("dd");
                const _this = this
                getActiceById(this.id).then(resp=>{
                    console.log(resp.data.list)
                    _this.blogData = resp.data.list
                    var MardownIt = require("markdown-it")
                    var md = new MardownIt()
                    var result = md.render(resp.data.list.content)
                    _this.blogData.content = result
                    console.log(_this.blogData)
                })
            }
        }
    }
</script>

<style scoped>
    .feed-foot{
        font-size: 12px;
    }

    .feed-legend-pipe {
        padding: 0 5px;
    }
    .feed-foot {
        color: #999;
        margin-top: 5px;
        white-space: nowrap;
    }

    .feed-legend {
        float: right;
        color: #999;
    }
    .module-body{
        margin-left: 20%;
        padding: 20px;
        background-color: white;
        width: 55%;
    }
    .head-pic {
        border-radius: 50%;
        display: block;
        float: left;
        margin-right: 10px;
        overflow: hidden;
        width: 50px;
        height: 50px;
    }
    .blog_bg{
        box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
        width: 60%;
        margin-top: 5% !important;
        margin-bottom: 5% !important;
        margin: auto;
        min-height: 500px;
    }
</style>
